package demo.practice.competition;

import java.util.Arrays;

public class P5797 {

    public static void main(String[] args) {
        P5797 p5797 = new P5797();
        p5797.maxProductDifference(new int[]{4, 2, 5, 9, 7, 4, 8});
    }

    public int maxProductDifference(int[] nums) {
        Arrays.sort(nums);
        return nums[nums.length - 1] * nums[nums.length - 2] - nums[0] * nums[1];
    }
}
